<template>
  <div class="container"> 
    <router-view
    :co-list="CoList"
    :travel-list="travelList"
    @like="like"
    ></router-view>
  </div>
</template>

<script>
import { getcolist,gettravelList } from "./assets/api/home";

  export default {
    data() {
      return {
        CoList: null,
        travelList:null
      };
    },
    methods:{
      like(value){
        console.log(value);
        let index = this.CoList.findIndex(item=>item.id==value.id);
        this.CoList[index].like = value.like;
        window.localStorage.setItem("like",JSON.stringify(this.CoList[index]));
      }
    },
    created(){
      getcolist().then((data)=>{
        this.CoList = data.data;
        console.log(this.CoList);
      })
      gettravelList().then((data)=>{
        this.travelList = data.travelList;
        console.log(this.travelList);
      })
    }
  }
</script>

<style lang="scss" scoped>
//公共样式
@import "./assets/css/index.css";
</style>